<?php
class DBO
{
    private $link;
    public function __construct()
    {
        $this->link=$dbh = new PDO('mysql:host=127.0.0.1;dbname=1705php', 'root', 'root');
        $this->link->setAttribute(PDO::ATTR_AUTOCOMMIT,1);
        $this->link->exec("set names utf8");
    }
    public function getNumber($table,$where="1")
    {
        if(empty($table))
        {
            return "不能为空";
        }

        $sql="select * from `$table` where $where";
        $data=$this->link->query($sql);
        return $data->rowCount();
    }

    //查询多条
    public function getAll($table,$limit,$size,$where="1")
    {
        if(empty($table))
        {
            return "不能为空";
        }
        $sql="select * from `$table` where $where limit $limit,$size";
        $data=$this->link->query($sql);
        return $data->fetchAll(2);
    }
}
//$db=new DBO();
//$res=$db->getOne("new");
//var_dump($res);

//$db=new DBO();
//$res=$db->getAll("games");
//var_dump($res);

?>